<?php
include_once "/var/www/html/new/com.inc.php";
include_once '/var/www/html/new/d/common/func.inc.php';
$account=$_REQUEST['username'];
$password=$_REQUEST['password'];

if(!ismobile($account))  exit('{"code":105,"msg":"账号格式不正确"}');

if($account!="" && $password!=""){

    if (ismobile($account)) {
        $where = "mobile='{$account}'";
    } else {
        $where = "account='{$account}'";
    }

    $sql="select id,account,dname,password,dtype,mobile from pft_member where {$where} limit 1";
    $GLOBALS['le']->query($sql);
    while($row=$GLOBALS['le']->fetch_assoc()){
        $list=$row;
    }
    if(empty($list)) exit('{"code":101,"msg":"账号未注册"}');
    
    // 验证密码
    if(md5(md5($password))!=$list['password']) exit('{"code":102,"msg":"密码不正确"}');
    
    // 缓存用户信息
    $_SESSION['sid'] = $list['id'];
    $_SESSION['memberID'] = $list['id'];
    $_SESSION['account'] = $list['account'];
    $_SESSION['sdtype'] = $list['dtype'];
    $_SESSION['dtype'] = $list['dtype'];
    $_SESSION['dname'] = $list['dname'];
    $name=$list['dname'];
	// if($_SERVER['HTTP_HOST']=='glyvc.12301.cc' && $list['mobile'] && strlen($list['account'])==6){
		// $_SESSION['account'] = $list['mobile'];
	// }
    exit('{"code":100,"msg":"'.$name.'"}');
}else{
	exit('{"code":104,"msg":"用户名或密码不能为空"}');
}
?>